package com.itheima.health.utils;

import com.alibaba.fastjson.JSON;
import com.itheima.health.pojo.result.Result;

import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class HttpUtil {
    /**
     * 写入响应内容
     * @param response
     * @param responseBody
     * @throws IOException
     */
    public static void write(HttpServletResponse response, Object responseBody) throws IOException {
        response.setContentType("application/json; charset=UTF-8");
        response.getWriter().write(JSON.toJSONString(responseBody));
    }
}
